        <!DOCTYPE html>
        <html>
        <head>
                <meta charset="utf-8">
        <title>CircleShape class / box2d_console Library / Dart Documentation</title>
        <link rel="stylesheet" type="text/css"
            href="../styles.css">
        <link href="http://fonts.googleapis.com/css?family=Open+Sans:400,600,700,800" rel="stylesheet" type="text/css">
        <link rel="shortcut icon" href="../favicon.ico">
        
        </head>
        <body data-library="box2d_console" data-type="CircleShape">
        <div class="page">
        <div class="header">
          <a href="../index.html"><div class="logo"></div></a>
          <a href="../index.html">Dart Documentation</a>
         &rsaquo; <a href="../box2d_console.html">box2d_console</a> &rsaquo; <a href="../box2d_console/CircleShape.html">CircleShape</a>        <div id="search-box">
          <input type="search" name="q" id="q" autocomplete="off"
              class="search-input" placeholder="Search API">
        </div>
        
      </div>
      <div class="drop-down" id="drop-down"></div>
      
        <div class="nav">
        
</div>
<div class="content">
        <h2><strong>CircleShape</strong>
          class
        </h2>
        
<button id="show-inherited" class="show-inherited">Hide inherited</button>
<div class="doc">
<p>A shape commonly known as the circle.</p>
<pre class="source">
class CircleShape extends Shape {
  /**
   * The current position of the center of this circle.
   */
  final Vector position;

  /**
   * A constructor for internal use only. Instead use Body.createShape with a
   * CircleDef.
   */
  CircleShape() :
    super(ShapeType.CIRCLE, 0),
    position = new Vector() {
  }

  /**
   * Constructs a new CircleShape equal to the given CircleShape.
   */
  CircleShape.copy(CircleShape other) :
    super(other.type, other.radius),
    position = new Vector.copy(other.position) { }


  /**
   * Returns true if the point is contained in the given shape when the given
   * rotation transform is applied. Implements superclass abstract method of
   * the same name.
   */
  bool testPoint(Transform transform, Vector point) {
    Vector center = new Vector();
    transform.rotation.multiplyVectorToOut(position, center);
    center.addLocal(transform.position);

    Vector d = center.subLocal(point).negateLocal();
    return Vector.dot(d, d) &lt;= radius * radius;
  }

  /**
   * Compute the axis aligned box for this Shape when the given transform is
   * applied. Stores the result in the given box.
   */
  void computeAxisAlignedBox(AxisAlignedBox argBox, Transform argTransform) {
    Vector p = new Vector();
    Matrix22.mulMatrixAndVectorToOut(argTransform.rotation, position, p);
    p.addLocal(argTransform.position);

    argBox.lowerBound.setCoords(p.x - radius, p.y - radius);
    argBox.upperBound.setCoords(p.x + radius, p.y + radius);
  }

  /** Returns a clone of this circle. */
  Shape clone() =&gt; new CircleShape.copy(this);

  /**
   * Computes the mass properties of this Circle at the given density and stores
   * the result in the given MassData object.
   */
  void computeMass(MassData massData, num density) {
    massData.mass = density * Math.PI * radius * radius;
    massData.center.setFrom(position);

    // Store inertia above the local origin.
    massData.inertia = massData.mass * (.5 * radius * radius +
        Vector.dot(position, position));
  }
}
</pre>
</div>
<h3>Extends</h3>
<p>
<span class="type-box"><span class="icon-class"></span><a href="../box2d_console/Shape.html">Shape</a></span>&nbsp;&gt;&nbsp;<span class="type-box"><span class="icon-class"></span><strong>CircleShape</strong></span></p>
<div>
<h3>Constructors</h3>
<div class="method"><h4 id="CircleShape">
<button class="show-code">Code</button>
new <strong>CircleShape</strong>() <a class="anchor-link" href="#CircleShape"
              title="Permalink to CircleShape.CircleShape">#</a></h4>
<div class="doc">
<p>A constructor for internal use only. Instead use Body.createShape with a
CircleDef.</p>
<pre class="source">
CircleShape() :
  super(ShapeType.CIRCLE, 0),
  position = new Vector() {
}
</pre>
</div>
</div>
<div class="method"><h4 id="CircleShape.copy">
<button class="show-code">Code</button>
new <strong>CircleShape.copy</strong>(<a href="../box2d_console/CircleShape.html">CircleShape</a> other) <a class="anchor-link" href="#CircleShape.copy"
              title="Permalink to CircleShape.CircleShape.copy">#</a></h4>
<div class="doc">
<p>Constructs a new CircleShape equal to the given CircleShape.</p>
<pre class="source">
CircleShape.copy(CircleShape other) :
  super(other.type, other.radius),
  position = new Vector.copy(other.position) { }
</pre>
</div>
</div>
</div>
<div>
<h3>Properties</h3>
<div class="field"><h4 id="position">
<button class="show-code">Code</button>
final <a href="../box2d_console/Vector.html">Vector</a>         <strong>position</strong> <a class="anchor-link"
            href="#position"
            title="Permalink to CircleShape.position">#</a>
        </h4>
        <div class="doc">
<p>The current position of the center of this circle.</p>
<pre class="source">
final Vector position;
</pre>
</div>
</div>
<div class="field inherited"><h4 id="radius">
<button class="show-code">Code</button>
num         <strong>radius</strong> <a class="anchor-link"
            href="#radius"
            title="Permalink to CircleShape.radius">#</a>
        </h4>
        <div class="inherited-from">inherited from <a href="../box2d_console/Shape.html">Shape</a> </div><div class="doc">
<p>Shape radius.</p>
<pre class="source">
num radius;
</pre>
</div>
</div>
<div class="field inherited"><h4 id="runtimeType">
<button class="show-code">Code</button>
final Type         <strong>runtimeType</strong> <a class="anchor-link"
            href="#runtimeType"
            title="Permalink to CircleShape.runtimeType">#</a>
        </h4>
        <div class="inherited-from">inherited from Object </div><div class="doc">
<p>A representation of the runtime type of the object.</p>
<pre class="source">
external Type get runtimeType;
</pre>
</div>
</div>
<div class="field inherited"><h4 id="type">
<button class="show-code">Code</button>
int         <strong>type</strong> <a class="anchor-link"
            href="#type"
            title="Permalink to CircleShape.type">#</a>
        </h4>
        <div class="inherited-from">inherited from <a href="../box2d_console/Shape.html">Shape</a> </div><div class="doc">
<p>The type of shape. Either circle or polygon.</p>
<pre class="source">
int type;
</pre>
</div>
</div>
</div>
<div>
<h3>Operators</h3>
<div class="method inherited"><h4 id="==">
<button class="show-code">Code</button>
bool <strong>operator ==</strong>(other) <a class="anchor-link" href="#=="
              title="Permalink to CircleShape.operator ==">#</a></h4>
<div class="inherited-from">inherited from Object </div><div class="doc">
<p>The equality operator.</p>
<p>The default behavior for all <code>Object</code>s is to return true if and
only if <code>this</code> and 
<span class="param">other</span> are the same object.</p>
<p>If a subclass overrides the equality operator it should override
the <code>hashCode</code> method as well to maintain consistency.</p>
<pre class="source">
bool operator ==(other) =&gt; identical(this, other);
</pre>
</div>
</div>
</div>
<div>
<h3>Methods</h3>
<div class="method"><h4 id="CircleShape">
<button class="show-code">Code</button>
new <strong>CircleShape</strong>() <a class="anchor-link" href="#CircleShape"
              title="Permalink to CircleShape.CircleShape">#</a></h4>
<div class="doc">
<p>A constructor for internal use only. Instead use Body.createShape with a
CircleDef.</p>
<pre class="source">
CircleShape() :
  super(ShapeType.CIRCLE, 0),
  position = new Vector() {
}
</pre>
</div>
</div>
<div class="method"><h4 id="CircleShape.copy">
<button class="show-code">Code</button>
new <strong>CircleShape.copy</strong>(<a href="../box2d_console/CircleShape.html">CircleShape</a> other) <a class="anchor-link" href="#CircleShape.copy"
              title="Permalink to CircleShape.CircleShape.copy">#</a></h4>
<div class="doc">
<p>Constructs a new CircleShape equal to the given CircleShape.</p>
<pre class="source">
CircleShape.copy(CircleShape other) :
  super(other.type, other.radius),
  position = new Vector.copy(other.position) { }
</pre>
</div>
</div>
<div class="method"><h4 id="clone">
<button class="show-code">Code</button>
<a href="../box2d_console/Shape.html">Shape</a> <strong>clone</strong>() <a class="anchor-link" href="#clone"
              title="Permalink to CircleShape.clone">#</a></h4>
<div class="doc">
<p>Returns a clone of this circle.</p>
<pre class="source">
Shape clone() =&gt; new CircleShape.copy(this);
</pre>
</div>
</div>
<div class="method"><h4 id="computeAxisAlignedBox">
<button class="show-code">Code</button>
void <strong>computeAxisAlignedBox</strong>(<a href="../box2d_console/AxisAlignedBox.html">AxisAlignedBox</a> argBox, <a href="../box2d_console/Transform.html">Transform</a> argTransform) <a class="anchor-link" href="#computeAxisAlignedBox"
              title="Permalink to CircleShape.computeAxisAlignedBox">#</a></h4>
<div class="doc">
<p>Compute the axis aligned box for this Shape when the given transform is
applied. Stores the result in the given box.</p>
<pre class="source">
void computeAxisAlignedBox(AxisAlignedBox argBox, Transform argTransform) {
  Vector p = new Vector();
  Matrix22.mulMatrixAndVectorToOut(argTransform.rotation, position, p);
  p.addLocal(argTransform.position);

  argBox.lowerBound.setCoords(p.x - radius, p.y - radius);
  argBox.upperBound.setCoords(p.x + radius, p.y + radius);
}
</pre>
</div>
</div>
<div class="method"><h4 id="computeMass">
<button class="show-code">Code</button>
void <strong>computeMass</strong>(<a href="../box2d_console/MassData.html">MassData</a> massData, num density) <a class="anchor-link" href="#computeMass"
              title="Permalink to CircleShape.computeMass">#</a></h4>
<div class="doc">
<p>Computes the mass properties of this Circle at the given density and stores
the result in the given MassData object.</p>
<pre class="source">
void computeMass(MassData massData, num density) {
  massData.mass = density * Math.PI * radius * radius;
  massData.center.setFrom(position);

  // Store inertia above the local origin.
  massData.inertia = massData.mass * (.5 * radius * radius +
      Vector.dot(position, position));
}
</pre>
</div>
</div>
<div class="method inherited"><h4 id="hashCode">
<button class="show-code">Code</button>
int <strong>hashCode</strong>() <a class="anchor-link" href="#hashCode"
              title="Permalink to CircleShape.hashCode">#</a></h4>
<div class="inherited-from">inherited from Object </div><div class="doc">
<p>Get a hash code for this object.</p>
<p>All objects have hash codes. Hash codes are guaranteed to be the
same for objects that are equal when compared using the equality
operator <code>==</code>. Other than that there are no guarantees about
the hash codes. They will not be consistent between runs and
there are no distribution guarantees.</p>
<p>If a subclass overrides <code>hashCode</code> it should override the
equality operator as well to maintain consistency.</p>
<pre class="source">
external int hashCode();
</pre>
</div>
</div>
<div class="method inherited"><h4 id="noSuchMethod">
<button class="show-code">Code</button>
<strong>noSuchMethod</strong>(String name, List args) <a class="anchor-link" href="#noSuchMethod"
              title="Permalink to CircleShape.noSuchMethod">#</a></h4>
<div class="inherited-from">inherited from Object </div><div class="doc">
<p><code>noSuchMethod</code> is invoked when users invoke a non-existant method
on an object. The name of the method and the arguments of the
invocation are passed to <code>noSuchMethod</code>. If <code>noSuchMethod</code>
returns a value, that value becomes the result of the original
invocation.</p>
<p>The default behavior of <code>noSuchMethod</code> is to throw a
<code>noSuchMethodError</code>.</p>
<pre class="source">
external Dynamic noSuchMethod(String name, List args);
</pre>
</div>
</div>
<div class="method inherited"><h4 id="Object">
<button class="show-code">Code</button>
const <strong>Object</strong>() <a class="anchor-link" href="#Object"
              title="Permalink to CircleShape.Object">#</a></h4>
<div class="inherited-from">inherited from Object </div><div class="doc">
<p>Creates a new <code>Object</code> instance.</p>
<p><code>Object</code> instances have no meaningful state, and are only useful
through their identity. An <code>Object</code> instance is equal to itself
only.</p>
<pre class="source">
const Object();
</pre>
</div>
</div>
<div class="method inherited"><h4 id="Shape">
<button class="show-code">Code</button>
new <strong>Shape</strong>([int type = ShapeType.UNKNOWN, num radius = 0]) <a class="anchor-link" href="#Shape"
              title="Permalink to CircleShape.Shape">#</a></h4>
<div class="inherited-from">inherited from <a href="../box2d_console/Shape.html">Shape</a> </div><div class="doc">
<p>Constructs a new shape of unknown type.</p>
<pre class="source">
Shape([int type = ShapeType.UNKNOWN, num radius = 0]) :
  type = type,
  radius = radius { }
</pre>
</div>
</div>
<div class="method"><h4 id="testPoint">
<button class="show-code">Code</button>
bool <strong>testPoint</strong>(<a href="../box2d_console/Transform.html">Transform</a> transform, <a href="../box2d_console/Vector.html">Vector</a> point) <a class="anchor-link" href="#testPoint"
              title="Permalink to CircleShape.testPoint">#</a></h4>
<div class="doc">
<p>Returns true if the point is contained in the given shape when the given
rotation transform is applied. Implements superclass abstract method of
the same name.</p>
<pre class="source">
bool testPoint(Transform transform, Vector point) {
  Vector center = new Vector();
  transform.rotation.multiplyVectorToOut(position, center);
  center.addLocal(transform.position);

  Vector d = center.subLocal(point).negateLocal();
  return Vector.dot(d, d) &lt;= radius * radius;
}
</pre>
</div>
</div>
<div class="method inherited"><h4 id="toString">
<button class="show-code">Code</button>
String <strong>toString</strong>() <a class="anchor-link" href="#toString"
              title="Permalink to CircleShape.toString">#</a></h4>
<div class="inherited-from">inherited from Object </div><div class="doc">
<p>Returns a string representation of this object.</p>
<pre class="source">
external String toString();
</pre>
</div>
</div>
</div>
        </div>
        <div class="clear"></div>
        </div>
        
        <div class="footer">
          
        </div>
        <script async src="../client-live-nav.js"></script>
        </body></html>
        
